package com.ssy.invoicing.common.util;

import java.io.Closeable;
import java.io.IOException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * IO流操作的工具类
 * @author shensuoyao
 */
public class IOUtil {

    private static Logger log = LoggerFactory.getLogger(IOUtil.class);

    private IOUtil(){
    }

    /**
     * 关闭流，请在finally块中执行
     * 
     * @param c
     */
    public static void close(Closeable c) {
        if (c != null) {
            try {
                c.close();
            } catch (IOException e) {
                log.error(e.getMessage(), e);
            }
        }
    }
    
    /**
     * 关闭流，请在finally块中执行
     * @param closeables
     */
    public static void closeAll(Closeable...closeables){
        if (closeables != null && closeables.length > 0){
            for(Closeable c : closeables){
                close(c);
            }
        }
    }
}
